<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
use dosamigos\datepicker\DatePicker;
$this->title = '用户资料';
$this->params['breadcrumbs'][] = $this->title;
$admin = Yii::$app->user->identity;
$pic =(empty($user->photos)||empty($user->photos->mp_main)) ?
    Yii::$app->params['img_path'].'photo/users/user-default.jpg':
    Yii::$app->params['img_path'].$user->photos->mp_main;
$arr = [
    '猴','鸡','狗','猪','鼠','牛','虎','兔','龙','蛇','马','羊'
];
?>
<div class="wrapper wrapper-content">
    <div class="row animated fadeInRight">
        <?php
        if(empty($user)){
            echo '<meta charset="utf-8"><h1>未找到该用户信息，请重试</h1>';
            exit;
        }
        ?>
        <div class="ibox-content">
        <div class="row">
        <div class="col-sm-5">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 style="color: #00B2E2">个人资料</h5>
                    <div class="ibox-tools">
                        <a title="编辑资料" data-toggle="modal" data-target="#myInfoDialog" data-date="edit">
                            <i class="fa fa-edit" style="color: black"></i>
                        </a>
                    </div>
                    <input id="mm_user_id" value="<?=$user['mi_id'] ?>" style="display: none;">
                </div>
                <div class="ibox-content no-padding border-left-right">
                    <div class="lightBoxGallery">
                        <a href="<?=$pic ?>" id="photo_main" title="正面照" data-gallery=""><img style="width: 360px" id="main_photo" src="<?=$pic ?>"></a>
                        <div id="blueimp-gallery" class="blueimp-gallery">
                            <div class="slides"></div>
                            <h3 class="title"></h3>
                            <a class="prev"><</a>
                            <a class="next">></a>
                            <a class="close">×</a>
                            <a class="play-pause"></a>
                            <ol class="indicator"></ol>
                        </div>
                    </div>
                </div>
                <div class="ibox-content profile-content" id="user-info" data-id="<?=Url::toRoute(['user/info','user_id'=>$user['mi_id']]) ?>">
                </div>
                <div class="ibox-title">
                    <h5 style="color: #00B2E2">近期约会</h5>
                    <div class="ibox-tools">
                        <a title="添加约会" data-toggle="modal" data-target="#myMettingDialog" data-data="add">
                            <i class="fa fa-plus" style="color: black"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="user-meeting" data-id="<?=Url::toRoute(['meet/list','user_id'=>$user['mi_id']]) ?>">
                    <input name="meet_page" value="1" type="hidden">
                    <?php
                    if(empty($meettings)){
                        echo '<h1 class="logo-name" style="font-size: 30px;text-align: center;letter-spacing: 0px">暂无约会记录..</h1>';
                    }else{?>
                     <table class="table" style="margin-top: -10px">
                         <?php
                        foreach($meettings as $meeting){
                            $meet = [
                                'mm_id'=>$meeting['mm_id'],
                                'mm_date'=>$meeting['mm_date'],
                                'mu_id'=>$meeting['mu_id']==$user['mi_id'] ? $meeting['mu_targrt']:$meeting['mu_id']
                            ]
                            ?>
                            <tr><td style="border-top: 0px;padding: 3px"><?=$meeting['mm_date'] ?></td>
                                <td  style="border-top: 0px;padding: 3px"><?=empty($targets[$meet['mu_id']]) ? '信息丢失':$targets[$meet['mu_id']] ?></td>
                                <td  style="border-top: 0px;padding: 3px"><a class="btn btn-white btn-xs" data-toggle="modal" data-target="#myMettingDialog" data-data='<?= \yii\helpers\Json::encode($meet) ?>'>
                                        <i class="fa fa-edit"></i>
                                    </a> <?php if(Yii::$app->user->identity->ma_type<3){?><a class="btn btn-white btn-xs" id="user_del" onclick="MeetDel(<?=$meeting['mm_id'] ?>)">
                                        <i class="fa fa-trash-o"></i>
                                    </a><?php } ?></td>
                            </tr>
                            <?php
                        }?>
                     </table>
                        <div class="f-r" style="text-align: center;margin-top: -20px">
                            <?= \yii\widgets\LinkPager::widget([
                                'pagination'=>$meetPage,
                                'class'=>'.pagination-sm',
                                'linkOptions' => ['onclick' => 'return goMeetPage(this)'],
                                'nextPageLabel' => '>>',
                                'prevPageLabel' => '<<',
                                'maxButtonCount' => 5,
                            ]) ?>
                        </div>
                         <?php
                    }
                    ?>
                </div>
                <?php
                if(!empty($user['healths'])&&($user['healths']['mh_history']=='有'||$user['healths']['mh_syntrophus']=='有')) {
                    ?>
                    <div class="ibox-title">
                        <h5 style="color: #00B2E2">病史</h5>

                        <div class="ibox-tools">
                            <a title="添加病史" data-toggle="modal" data-target="#myIllDialog" data-data="add">
                                <i class="fa fa-plus" style="color: black"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" id="user-ill" data-id="<?=Url::toRoute(['ill/list','user_id'=>$user['mi_id']]) ?>">
                        <input name="ill_page" value="1" type="hidden">
                    </div>
                    <?php
                }
                ?>
            </div>
        </div>
            <div class="clearfix visible-sm"></div>
        <div class="col-sm-7">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 style="color: #00B2E2">家庭成员</h5>
                    <div class="ibox-tools" style="margin-right: 20px;">
                        <a title="添加家庭成员"  data-toggle="modal" data-target="#myFamilyDialog" data-data="add">
                            <i class="fa fa-plus" style="color: black"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="user-family" data-id="<?=Url::toRoute(['family/list','user_id'=>$user['mi_id']]) ?>">
                    <input name="family_page" value="1" type="hidden">
                </div>
                <div class="ibox-title">
                    <h5 style="color: #00B2E2">恋爱经历</h5>
                    <div class="ibox-tools" style="margin-right: 20px;">
                        <a title="添加恋爱经历" data-toggle="modal" data-target="#myExperienceDialog" data-data="add">
                            <i class="fa fa-plus" style="color: black"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="user-experience" data-id="<?=Url::toRoute(['experience/list','user_id'=>$user['mi_id']]) ?>">
                    <input name="experience_page" value="1" type="hidden">
                </div>
                <div class="ibox-title" id="requirement_title">
                    <h5 style="color: #00B2E2">择偶要求</h5>
                        <?php
                        if(empty($user['requirements'])){
                            echo '<div class="ibox-tools" style="margin-right: 20px;">
                        <a title="添加择偶要求" data-toggle="modal" data-target="#myRequirementDialog" data-data="add">
                            <i class="fa fa-plus" style="color: black"></i>
                        </a>
                    </div>';
                        }else{ ?>
                            <div class="ibox-tools" style="margin-right: 20px">
                        <a title="编辑择偶要求" data-toggle="modal" data-target="#myRequirementDialog" data-data=<?=\yii\helpers\Json::encode($user['requirements']) ?>>
                            <i class="fa fa-edit" style="color: black"></i>
                        </a>
                    </div>
                    <?php
                        }
                        ?>
                </div>
                <div class="ibox-content" id="user-requirement" data-id="<?=Url::toRoute(['requirement/list','user_id'=>$user['mi_id']]) ?>">
                </div>
                <div class="ibox-title" id="photo_title">
                    <h5 style="color: #00B2E2">相册</h5>
                    <div class="ibox-tools" style="margin-right: 20px;">
                        <a title="上传照片" id="upload-photo" data-toggle="modal" data-target="#myPhotoDialog"
                           data-data=<?=empty($user['photos'])||empty($user['photos']['mp_other']) ? ' ':$user['photos']['mp_other'] ?>>
                            <i class="fa fa-upload" style="color: black"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="user-photos" data-id="<?=Url::toRoute(['photo/list','user_id'=>$user['mi_id']]) ?>">
                </div>
                <div class="ibox-title">
                    <h5 style="color: #00B2E2">印象墙</h5>
                    <div class="ibox-tools" style="margin-right: 20px;">
                        <a title="添加印象" data-toggle="modal" data-target="#myCommentDialog">
                            <i class="fa fa-plus" style="color: black"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content" id="user-comment" data-id="<?=Url::toRoute(['comment/list','user_id'=>$user['mi_id']]) ?>">
                  <input id="comment_page" value="1" style="display: none;">
                </div>
            </div>
        </div>
        </div>
            </div>
    </div>
</div>
<style>
    .datepicker {
        z-index: 9999 !important;
    }
</style>
<div class="modal inmodal fade" id="myInfoDialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" >
    <?php $form = ActiveForm::begin([
        'id'=>'user_edit',
        'action' => Url::toRoute(['user/update','id'=>$user['mi_id']]),
        'enableAjaxValidation'=>true, //开启Ajax验证
        'validationUrl' => Url::toRoute(['user/valid-form','id'=>$user['mi_id']]),
    ]); ?>
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title"><i class="fa fa-table"></i> 编辑客户-<?=$user['mi_name'] ?></h4>
        </div>
        <div class="modal-body">
            <div id="base_info">
                <h3 style="color: #00a2d4;">基本信息</h3>
                <div class="row">
                    <div class="col-sm-3">
                        <?= $form->field($user,'mi_name')->textInput(['maxlength'=>true])->label('姓 名') ?></div>
                    <div class="col-sm-2">
                        <?= $form->field($user,'mi_sex')->radioList(['男'=>'男','女'=>'女'])->label('性 别') ?></div>
                    <div class="col-sm-2">
                        <?= $form->field($user,'mi_height')->textInput([
                            'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")',
                            'placeholder'=>'单位：cm'
                        ])->label('身 高') ?>
                    </div>
                    <div class="col-sm-2">
                        <?= $form->field($user,'mi_weight')->textInput([
                            'onkeyup'=>'clearNoNum(this)',
                            'placeholder'=>'单位：kg'])->label('体 重') ?></div>
                </div>
                <div class="row">
                    <div class="col-sm-3">
                        <?=$form->field($user, 'mi_birth')->widget(
                            DatePicker::className(), [
                            'value' => date('yyyy年mm月',time()),
                            // inline too, not bad
                            'inline' => false,
                            'language'=>'zh-CN',
                            'options'=>[
                                'readonly'=>true,
                            ],
                            // modify template for custom rendering
                            'clientOptions' => [
                                'autoclose' => true,
                                'minViewMode'=>1,
                                'keyboardNavigation'=>false,
                                'forceParse'=>false,
                                'format' => 'yyyy年mm月',
                                'readonly'=>true,
                            ]
                        ]); ?>
                    </div><div class="col-sm-2">
                        <?= $form->field($user,'mi_zodiac')->textInput(['readonly'=>true,'value'=>$arr[(date('Y',time())%12)],'style'=>'width:100px'])->label('属 相') ?>
                    </div><div class="col-sm-2">
                        <?= $form->field($user,'mi_edu')->dropDownList([
                            '博士'=>'博士','硕士'=>'硕士','本科'=>'本科','大专'=>'大专','高中'=>'高中','初中'=>'初中','文盲'=>'文盲'
                        ],[
                            'prompt'=>'请选择学历'])->label('学 历') ?>
                    </div><div class="col-sm-2">
                        <?= $form->field($user['details'],'md_marry')->dropDownList([
                            '未婚'=>'未婚','离异'=>'离异','丧偶'=>'丧偶'
                        ]) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-5">
                        <div class="form-group">
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div style="display: none;margin-top: 0px;margin-bottom: 0px">
                                    <?= $form->field($user,'mi_root')->hiddenInput() ?></div>
                                <div class="col-sm-12" style="margin-top: 0px;margin-bottom: 0px">
                                    <label class="control-label">籍 贯</label>
                                </div>
                            </div>
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div class="col-sm-6" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="info_privince" class="form-control" name="info_privince">
                                        <?php
                                        $localtion = explode(';',$user['mi_root']);
                                        foreach($privinces as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?>" <?php if($val==$localtion[0]){echo 'selected';} ?>><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div><div class="col-sm-6" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="info_city" class="form-control" name="info_city">
                                        <?php
                                        foreach($cities as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?>" <?php if($val==$localtion[1]){echo 'selected';} ?>><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div></div>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <?= $form->field($user,'mi_cardid')->textInput(['maxlength'=>true,'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")']) ?></div>
                    <div class="col-sm-3">
                        <?= $form->field($user,'mi_sight')->dropDownList([
                            '正常'=>'正常','近视'=>'近视','轻度近视'=>'轻度近视','高度近视'=>'高度近视','远视'=>'远视','盲人'=>'盲人'
                        ],[
                            'value'=>'正常']) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-3">
                        <?= $form->field($user['healths'],'mh_state')->dropDownList([
                            '健康'=>'健康','亚健康'=>'亚健康','非健康'=>'非健康'
                        ],[
                            'value'=>'健康']) ?>
                    </div>
                    <div class="col-sm-3">
                        <?= $form->field($user['healths'],'mh_history')->radioList(['有'=>'有','无'=>'无'],['id'=>'detail_child']) ?></div>
                    <div class="col-sm-3">
                        <?= $form->field($user['healths'],'mh_syntrophus')->radioList(['有'=>'有','无'=>'无'],['id'=>'detail_child']) ?>
                    </div>
                </div>
            </div>
            <div id="contact_ways">
                <h3 style="color: #00a2d4">联系方式</h3>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div style="display: none;margin-top: 0px;margin-bottom: 0px">
                                    <?= $form->field($user['extras'],'me_postion')->hiddenInput() ?></div>
                                <div class="col-sm-12" style="margin-top: 0px;margin-bottom: 0px">
                                    <label class="control-label">现居地</label>
                                </div>
                            </div>
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div class="col-sm-3" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="extra_privince" class="form-control" name="extra_privince">
                                        <?php
                                        $postion = explode(';',$user['extras']['me_postion']);
                                        foreach($privinces as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?>" <?php if($val==$postion[0]){echo 'selected';} ?>><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div><div class="col-sm-3" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="extra_city" class="form-control" name="extra_city">
                                        <?php
                                        foreach($cities as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?>" <?php if($val==$postion[1]){echo 'selected';} ?>><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div><div class="col-sm-3" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="extra_district" class="form-control" name="extra_district">
                                        <?php
                                        foreach($districts as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?> <?php if($val==$postion[2]){echo 'selected';} ?>"><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div>
                                <div class="col-sm-3">
                                    <?= $form->field($user['extras'],'me_address')->textInput(['placeholder'=>'请输入详细地址'])->label(false) ?></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-3">
                        <?= $form->field($user['extras'],'me_phone')->textInput(['maxlength'=>true,'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")']) ?></div><div class="col-sm-3">
                        <?= $form->field($user['extras'],'me_qq')->textInput(['maxlength'=>true,'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")']) ?></div><div class="col-sm-3">
                        <?= $form->field($user['extras'],'me_wx')->textInput() ?></div>
                </div>
            </div>
            <div id="user_detail">
                <h3 style="color: #00a2d4">现 状</h3>
                <div class="row"><div class="col-sm-4">
                        <?= $form->field($user['details'],'md_work')->textInput() ?></div><div class="col-sm-2">
                        <?= $form->field($user['details'],'md_mon_salary')->textInput(['onkeyup'=>'clearNoNum(this)',
                            'placeholder'=>'单位：元'])->label('月 薪') ?></div><div class="col-sm-2">
                        <?= $form->field($user['details'],'md_year_salary')->textInput(['onkeyup'=>'clearNoNum(this)',
                            'placeholder'=>'单位：元'])->label('年 薪') ?></div>
                </div>
                <div class="row"><div class="col-sm-3">
                        <?= $form->field($user['extras'],'me_env')->dropDownList([
                            '独居'=>'独居','与亲人住一起'=>'与亲人住一起','与朋友合租'=>'与朋友合租','与陌生人合租'=>'与陌生人合租'
                        ]) ?></div><div class="col-sm-3">
                        <?= $form->field($user['extras'],'me_livetype')->dropDownList([
                            '住房'=>'住房','存量房'=>'存量房','商品房'=>'商品房'
                        ]) ?></div>
                    <div class="col-sm-2">
                        <div class="form-group">
                            <div style="margin-top: 30px"><label><input id="md_isowner" value="0" type="checkbox"
                                        <?php if($user['details']['md_isowner']=='有'){echo 'checked';} ?>> 有 房</label></div>
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <div class="form-group">
                            <div style="margin-top: 30px"><label><input id="md_hascar" value="0" type="checkbox"
                                        <?php if($user['details']['md_hascar']=='有'){echo 'checked';} ?>> 有 车</label></div>
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <div class="form-group">
                            <div style="margin-top: 30px"><label><input id="md_loan" value="0" type="checkbox"
                                        <?php if($user['details']['md_loan']=='有'){echo 'checked';} ?>> 有贷款</label></div>
                        </div>
                    </div>
                    <div style="display: none;margin-top: 0px;margin-bottom: 0px">
                        <?= $form->field($user['details'],'md_isowner')->hiddenInput() ?>
                        <?= $form->field($user['details'],'md_hascar')->hiddenInput() ?>
                        <?= $form->field($user['details'],'md_loan')->hiddenInput() ?></div>
                </div>
                <div class="row">
                    <div class="col-sm-12" id="house_location" style="display:<?=$user['details']['md_isowner']=='有' ? 'block':'none' ?>;">
                        <div class="form-group">
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div style="display: none;margin-top: 0px;margin-bottom: 0px">
                                    <?= $form->field($user['details'],'md_location')->hiddenInput() ?></div>
                                <div class="col-sm-12" style="margin-top: 0px;margin-bottom: 0px">
                                    <label class="control-label">房屋地址</label>
                                </div>
                            </div>
                            <div class="row" style="margin-top: 0px;margin-bottom: 0px">
                                <div class="col-sm-4" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="detail_privince" class="form-control" name="detail_privince">
                                        <option value="0" selected>请选择省份</option>
                                        <?php
                                        $housePos = explode(';',$user['details']['md_location']);
                                        if(count($housePos)<3){
                                            $housePos[0]='请选择省份';
                                            $housePos[1]='请先选择省份';
                                            $housePos[2]='请先选择省份';
                                        }
                                        foreach($privinces as $key=>$val){
                                            ?>
                                            <option value="<?=$key ?>" <?php if($housePos[0]==$val){echo 'selected';} ?>><?=$val ?></option>
                                            <?php
                                        } ?>
                                    </select></div><div class="col-sm-4" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="detail_city" class="form-control" name="detail_city" disabled>
                                        <option value="<?=$housePos[1] ?>" selected><?=$housePos[1] ?></option>
                                    </select></div><div class="col-sm-4" style="margin-top: 0px;margin-bottom: 0px">
                                    <select id="detail_district" class="form-control" name="detail_district" disabled>
                                        <option value="<?=$housePos[2] ?>" selected><?=$housePos[2] ?></option>
                                    </select></div></div>
                        </div>
                    </div>
                </div>
            <div class="row">
                <div class="col-sm-4" id="house_address" style="display: <?=$user['details']['md_isowner']=='有' ? 'block':'none' ?>">
                    <?= $form->field($user['details'],'md_house_address')->textInput([
                        'placeholder'=>'请输入房屋详细地址']) ?>
                </div>
                <div class="col-sm-2" id="house_area" style="display: <?=$user['details']['md_isowner']=='有' ? 'block':'none' ?>">
                    <?= $form->field($user['details'],'md_house_area')->textInput([
                        'onkeyup'=>'clearNoNum(this)',
                        'placeholder'=>'单位：㎡']) ?>
                </div>
            </div>
                <div class="row">
                    <div class="col-sm-2" id="car_type" style="display: <?=$user['details']['md_hascar']=='有' ? 'block':'none' ?>">
                        <?= $form->field($user['details'],'md_cartype')->textInput([
                            'placeholder'=>'如：奥迪A3'])->label('车 型') ?>
                    </div>
                    <div class="col-sm-3" style="display:<?=$user['details']['md_marry']=='离异' ? 'block':'none' ?>" id="md_despid">
                        <?= $form->field($user['details'],'md_despid')->textInput() ?></div>
                    <div class="col-sm-2" style="display: <?=$user['details']['md_marry']=='离异'||$user['details']['md_marry']=='丧偶'
                        ? 'block':'none' ?>" id="md_child">
                        <?= $form->field($user['details'],'md_child')->radioList(['有'=>'有','无'=>'无'],['id'=>'detail_child']) ?></div>
                    <div class="col-sm-3" style="display:<?=$user['details']['md_child']=='有' ? 'block':'none' ?>" id="md_child_belong">
                        <?= $form->field($user['details'],'md_child_belong')->dropDownList([
                            '己方'=>'己方','对方'=>'对方','他人'=>'他人'
                        ],['prompt'=>'请选择小孩归属']) ?></div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <?= $form->field($user['details'],'md_selfdiscr')->textarea(['maxlength'=>true,'placeholder'=>'最多100字','rows'=>3]) ?></div>
                </div>
            </div>
            <div id="user_detail">
                <h3 style="color: #00a2d4">正面照</h3>
                <div class="col-sm-12">
                    <?= $form->field($photo , 'mp_main')->label(false)->widget(\kartik\file\FileInput::className(),[
                        'options'   => [
                            'multiple' => false,
                            'autoReplace'=>true,
                        ],
                        'pluginOptions' => [
                            'initialPreview' => $pic,
                            'initialPreviewAsData' => true,
                            'removeFromPreviewOnError'=>false,
                            'allowedFileTypes'=>['image'],
                            'allowedFileExtensions'=>['png', 'jpg', 'jpeg'],
                            'uploadUrl' => Url::toRoute(['user/upload']),
                            'uploadExtraData' => [
                                'id' => $user['mi_id'],
                            ],
                            'uploadAsync' => true,
                            'minFileCount' => 1,
                            'maxFileCount' => 1,
                            'showRemove' => true,
                            'showUpload' => true,
                            'showBrowse' => true,
                            'browseOnZoneClick' => false,
                            'autoReplace'=>true,
                            'fileActionSettings' => [
                                'showZoom' => false,
                                'showUpload' => true,
                                'showRemove' => false,
                            ],
                        ],
                        'pluginEvents'  => [
                            'fileuploaded'  => "function (object,data){
			                    $('.field-userphoto-mp_main').find('input').attr('value',data.response.imageUrl);
		                    }",
                            //错误的冗余机制
                            'error' => "function (){
			                    alert('data.error');
		                    }"
                        ],
                    ]);?>
                    </div>
                </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
        </div>
    </div>

    <?php ActiveForm::end(); ?>
</div>
</div>
<div class="modal inmodal fade" id="myMettingDialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm" >
    <?php $meetForm = ActiveForm::begin([
        'id'=>'meetting-form',
        'action' => Url::toRoute(['meet/add','id'=>$user['mi_id']]),
    ]); ?>
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">约会管理</h4>
        </div>
        <div class="modal-body">
            <?=$meetForm->field($meetModel,'mm_id')->hiddenInput()->label(false) ?>
            <?=$meetForm->field($meetModel,'mu_targrt')->dropDownList($targets,['prompt'=>'选择约会对象']) ?>
            <?=$meetForm->field($meetModel, 'mm_date')->widget(
                DatePicker::className(), [
                'value' => date('yyyy-mm-dd',time()),
                // inline too, not bad
                'inline' => true,
                'language'=>'zh-CN',
                'options'=>[
                    'readonly'=>true,
                ],
                // modify template for custom rendering
                'clientOptions' => [
                    'linkFormat' => 'yyyy-mm-dd', // if inline = true
                    'minViewMode'=>0,
                    'keyboardNavigation'=>false,
                    'forceParse'=>false,
                    'format' => 'yyyy-mm-dd',
                    'readonly'=>true,
                ]
            ]); ?>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
        </div>
    </div>

    <?php ActiveForm::end(); ?>
</div>
</div>
<div class="modal inmodal fade" id="myIllDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm" >
        <?php $meetForm = ActiveForm::begin([
            'id'=>'ill-form',
            'action' => Url::toRoute(['ill/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">病历管理</h4>
            </div>
            <div class="modal-body">
                <?=$meetForm->field($ill,'mi_id')->hiddenInput()->label(false) ?>
                <?=$meetForm->field($ill,'mi_type')->textInput() ?>
                <?=$meetForm->field($ill, 'mi_cure')->radioList(['已痊愈'=>'已痊愈','未痊愈'=>'未痊愈']); ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<div class="modal inmodal fade" id="myFamilyDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" >
        <?php $meetForm = ActiveForm::begin([
            'id'=>'family-form',
            'action' => Url::toRoute(['family/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">家庭成员管理</h4>
            </div>
            <div class="modal-body">
                <?=$meetForm->field($family,'mf_id')->hiddenInput()->label(false) ?>
                <?=$meetForm->field($family, 'mr_id')->dropDownList($relation,['prompt'=>'请选择关系']); ?>
                <?=$meetForm->field($family, 'mf_name')->textInput(); ?>
                <?=$meetForm->field($family, 'mf_age')->textInput(['maxlength'=>true,'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")']); ?>
                <?=$meetForm->field($family, 'mf_type')->textInput(); ?>
                <?=$meetForm->field($family, 'mf_phone')->textInput(['maxlength'=>true,'onkeyup'=>'this.value=this.value.replace(/\D/gi,"")']); ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<div class="modal inmodal fade" id="myExperienceDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" >
        <?php $meetForm = ActiveForm::begin([
            'id'=>'experience-form',
            'action' => Url::toRoute(['experience/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">恋爱经历</h4>
            </div>
            <div class="modal-body">
                <?=$meetForm->field($experience,'me_id')->hiddenInput()->label(false) ?>
                <?=$meetForm->field($experience, 'me_discription')->textarea(['maxlength'=>true,'placeholder'=>'最多200字','rows'=>8]) ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<div class="modal inmodal fade" id="myCommentDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" >
        <?php $meetForm = ActiveForm::begin([
            'id'=>'comment-form',
            'action' => Url::toRoute(['comment/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">恋爱经历</h4>
            </div>
            <div class="modal-body">
                <?=$meetForm->field($comment,'mc_id')->hiddenInput()->label(false) ?>
                <?=$meetForm->field($comment, 'mc_detail')->textarea(['maxlength'=>true,'placeholder'=>'最多100字','rows'=>5]) ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<div class="modal inmodal fade" id="myRequirementDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg" >
        <?php $meetForm = ActiveForm::begin([
            'id'=>'requirement-form',
            'action' => Url::toRoute(['requirement/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">择偶标准</h4>
            </div>
            <div class="modal-body">
                <?=$meetForm->field($requirement,'mr_id')->hiddenInput()->label(false) ?>
                <div class="row">
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_work')->textInput() ?>
                    </div>
                    <div class="col-sm-6">
                    <?=$meetForm->field($requirement,'mr_ecom')->textInput() ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_home')->textInput() ?>
                    </div>
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_edu')->textInput() ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_looks')->textInput() ?>
                    </div>
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_figure')->textInput() ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_house')->textInput() ?>
                    </div>
                    <div class="col-sm-6">
                        <?=$meetForm->field($requirement,'mr_car')->textInput() ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4">
                        <?=$meetForm->field($requirement,'mr_isdissociated')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                    <div class="col-sm-4">
                        <?=$meetForm->field($requirement,'mr_hadchild')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                    <div class="col-sm-4">
                        <?=$meetForm->field($requirement,'mr_issick')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-3">
                        <?=$meetForm->field($requirement,'mr_withparents')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                    <div class="col-sm-3">
                        <?=$meetForm->field($requirement,'mr_wantchild')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                    <div class="col-sm-3">
                        <?=$meetForm->field($requirement,'mr_quickmerry')->radioList(['是'=>'是','否'=>'否']) ?>
                    </div>
                    <div class="col-sm-3">
                        <?=$meetForm->field($requirement,'mr_merryperiod')->dropDownList([
                            '1年之内'=>'1年之内','1年~2年'=>'1年~2年','2年~3年'=>'2年~3年','3年以上'=>'3年以上',
                        ],['prompt'=>'请选择']) ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <?=$meetForm->field($requirement,'mr_other')->textarea(['maxlength'=>true,'placeholder'=>'最多200字','rows'=>5]) ?>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<div class="modal inmodal fade" id="myPhotoDialog" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" >
        <?php $form = ActiveForm::begin([
            'id'=>'photo-form',
            'action' => Url::toRoute(['photo/add','id'=>$user['mi_id']]),
        ]); ?>
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">上传图片</h4>
                <small>个人相册最多存5张相片，若提示超出，请先删除无关相片</small>
            </div>
            <div class="modal-body">
                <?= $form->field($photo,'mp_other')->label(false)->widget(\kartik\file\FileInput::className(),[
                    'options'   => [
                        'multiple' => true,
                        'autoReplace'=>true,
                    ],
                    'pluginOptions' => [
                        'initialPreview' => '',
                        'initialPreviewAsData' => false,
                        'removeFromPreviewOnError'=>false,
                        'allowedFileTypes'=>['image'],
                        'allowedFileExtensions'=>['png', 'jpg', 'jpeg'],
                        'uploadUrl' => Url::toRoute(['photo/upload']),
                        'uploadExtraData' => [
                            'id' => $user['mi_id'],
                        ],
                        'minFileCount' => 1,
                        'maxFileCount' => 5,
                        'showRemove' => true,
                        'showUpload' => true,
                        'showBrowse' => true,
                        'browseOnZoneClick' => false,
                        'autoReplace'=>true,
                        'fileActionSettings' => [
                            'showZoom' => false,
                            'showUpload' => true,
                            'showRemove' => true,
                        ],
                    ],
                    'pluginEvents'  => [
                        'fileuploaded'  => "function (object,data){
                        var photo = $('#userphoto-url').val();
                        $('#userphoto-url').val(photo+data.response.imageUrl);
		                    }",
                        'filecleared' => "function(){
                        val = $('#upload-photo').data('data');
                        if(val==''){
                        $('#userphoto-url').val('');
                        }else{
                        $('#userphoto-url').val(val.mp_other);
                        }
		                    }",
                        //错误的冗余机制
                        'error' => "function (){
			                    alert('data.error');
		                    }",
                    ],
                ]);?>
                <?=$form->field($photo,'url')->hiddenInput()->label(false) ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>

        <?php ActiveForm::end(); ?>
    </div>
</div>
<?=Html::jsFile('@web/js/marriage/update.js?_'.time())?>
<script>
    $(window).ready(function(){
        logo = $('#main_photo')[0];
        var img = new Image();
        img.src = logo.src;
        img.onerror = function(){
            logo.src = '/marriage/admin/web/photo/users/user-default.jpg';
            $('#photo_main')[0].href = '/marriage/admin/web/photo/users/user-default.jpg';
            $('#user_edit').find('img')[0].src = '/marriage/admin/web/photo/users/user-default.jpg'
        };
    });
</script>
